package com.learn.design.abstractfactory.handler;

import com.learn.design.abstractfactory.adapter.ICacheAdapter;

import java.lang.reflect.Proxy;
import java.util.*;
import java.util.concurrent.TimeUnit;

/**
 * @author xuhainan
 * @date 2023/8/1 17:02
 * @region hefei
 */
public class JDKProxy {

    public static <T> T getProxy(Class<T> interfaceClass, ICacheAdapter cacheAdapter) {
        ICacheAdapterJDKInvocationHandler handler = new ICacheAdapterJDKInvocationHandler(cacheAdapter);
        return (T) Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class[]{interfaceClass}, handler);

    }


}
